<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // 获取表单数据
    $host = htmlspecialchars($_POST['host']);
    $dbname = htmlspecialchars($_POST['dbname']);
    $username = htmlspecialchars($_POST['username']);
    $password = htmlspecialchars($_POST['password']);
    $charset = htmlspecialchars($_POST['charset']);

    // 配置文件内容
    $configContent = "<?php\nreturn [\n    'host' => '$host',\n    'dbname' => '$dbname',\n    'username' => '$username',\n    'password' => '$password',\n    'charset' => '$charset',\n];\n";

    // 写入配置文件
    file_put_contents('db_config.php', $configContent);


    // 包含或执行另一个PHP文件
    require '创建数据表.php'; // 确保替换为你的目标PHP文件名
} else {
    echo "无效的请求。";
}
?>
